<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="th/m/include/head_css :: head(~{::title}, ~{::link}, ~{::style})">
    <meta charset="utf-8">
    <title>部门</title>
    <style></style>
    <link type="text/css" rel="stylesheet" th:href="@{/js/jstree/themes/default/style.css}"/>
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <h1 class="mui-title">部门</h1>
</header>
<div class="mui-content mui-scroll-wrapper">
    <div class="mui-scroll">
        <div id="deptTree"></div>
        <iframe id="ifrmGetChildren" style="display:none" width="300" height="300" src=""></iframe>
    </div>
</div>
<script th:src="@{/js/jstree/jstree.js}"></script>
<script th:src="@{/weixin/js/macro/open_window_macro.js}"></script>
<script th:inline="javascript" charset="utf-8">
    mui('.mui-scroll-wrapper').scroll({
        deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });

    function selectNode(formCode, code, name) {
        window.parent.selectNode(formCode, code, name);
        window.parent.closeIframe();
    }

    function bindClick() {
        $("a").bind("click", function () {
            $("a").css("color", "");
            $(this).css("color", "red");
        });
    }

    $(document).ready(function () {
        $('#deptTree').jstree({
            "core": {
                "data": [(${jsonData})],
                "themes": {
                    "theme": "default",
                    "dots": true,
                    "icons": true
                },
                "check_callback": true,
            },
            "plugins": ["wholerow", "themes", "ui", , "types", "state"],
        }).bind('click.jstree', function (e, data) {
            //绑定选中事件
            var eventNodeName = e.target.nodeName;
            if (eventNodeName == 'INS') {
                return;
            } else if (eventNodeName == 'A') {
                var $subject = $(e.target).parent();
                if ($subject.find('ul').length > 0) {
                } else {
                    //选择的id值
                    var code = $(e.target).parents('li').attr('id');
                    var name = $subject.text();
                    var formCode = '<%=formCode%>';
                    selectNode(formCode, code, name);
                }
            }
        });
        bindClick();
    });
</script>
</body>
</html>
